package com.msb.config;


import com.msb.bean.Book;
import com.msb.bean.Person;
import com.msb.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @author sunpeng
 * @Date 2021-07-13 15:12
 */
@Configuration
@ComponentScan(basePackages = "com.msb")
@PropertySource("classpath:userConfig.properties")
public class MyConfig {

    @Value("${myUser.name}")
    private String name;

    @Bean
    public Person getPerson(){
        Person person = new Person();
        person.setName(name);
        return person;
    }

    @Bean(value = "goodBook")
    public Book getBook(@Qualifier(value = "getPerson") Person person){
        System.out.println(person);
        return new Book();
    }
}
